package org.bugeden.netdisk.transfer

import org.bugeden.netdisk.user.IUser

/**
 * Created by IntelliJ IDEA.
 * User: gzhang
 * Date: 2010-6-19
 * Time: 22:55:02
 * To change this template use File | Settings | File Templates.
 */

trait IDevice{
  import IDevice._

  @throws(classOf[NotBindingException])
  @throws(classOf[UnExistBlockException])
  def write(block: Block): Block

  @throws(classOf[NotBindingException])
  @throws(classOf[UnExistBlockException])
  def read(block: Block): Option[Block]

  @throws(classOf[NotBindingException])
  @throws(classOf[UnExistBlockException])
  def remove(block: Block): Block

  @throws(classOf[NotBindingException])
  @throws(classOf[UnExistBlockException])
  def update(block: Block): Block

  def isBlockExist(block: Block): Boolean

  def flush(): Unit

  def unbind(): Unit

  @throws(classOf[NotBindingException])
  def bind(user: IUser): Unit
}

object IDevice{
  class DeviceException extends RuntimeException
  class NotBindingException extends DeviceException
  class UnExistBlockException extends DeviceException

}
